﻿<Page x:Class="Samples.Pages.DiskPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="DiskPage"
      
    xmlns:l="clr-namespace:TreeMaps.Controls;assembly=TreeMaps"

    >
  <Page.Resources>
    <DataTemplate x:Key="driveDataTemplate">
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding Path=Name}" Margin ="0,0,0,1"/>
        <TextBlock Text="{Binding Path=VolumeLabel}"/>
      </StackPanel>
    </DataTemplate>

    <HierarchicalDataTemplate x:Key="diskItemDataTemplate" ItemsSource="{Binding Path=SubItems}">
      <Border Background="Transparent">
        <Border.ToolTip>
          <StackPanel Orientation="Vertical">
            <TextBlock Text="{Binding Path=Text}" Margin="0,0,0,2"/>
            <TextBlock Text="{Binding Path=Value}" />
          </StackPanel>
        </Border.ToolTip>
        <Grid/>
      </Border>
    </HierarchicalDataTemplate>

    <Style TargetType="{x:Type l:TreeMapItem}">
      <Setter Property="Padding" Value="0"/>
      <Setter Property="BorderBrush" Value="Transparent"/>
      <Setter Property="BorderThickness" Value="0"/>
      <Setter Property="Background" >
        <Setter.Value>
          <RadialGradientBrush
              GradientOrigin="0.2,0.2"
              Center="0.2,0.2" RadiusX="1" RadiusY="1">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="White" Offset="0" />
              <GradientStop Color="LightGray" Offset="0.1" />
              <GradientStop Color="Black" Offset="1" />
            </RadialGradientBrush.GradientStops>
          </RadialGradientBrush>
        </Setter.Value>
      </Setter>

      <Setter Property="Opacity" Value=".75"/>
      <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="true">
          <Setter Property="BorderBrush" Value="Red"/>
          <Setter Property="BorderThickness" Value="1"/>
          <Setter Property="Background" >
            <Setter.Value>
              <RadialGradientBrush
                  GradientOrigin="0.2,0.2"
                  Center="0.2,0.2" RadiusX="1" RadiusY="1">
                <RadialGradientBrush.GradientStops>
                  <GradientStop Color="DarkGray" Offset="0" />
                  <GradientStop Color="LightGray" Offset="0.1" />
                  <GradientStop Color="White" Offset="1" />
                </RadialGradientBrush.GradientStops>
              </RadialGradientBrush>
            </Setter.Value>
          </Setter>
        </Trigger>
      </Style.Triggers>
    </Style>
  </Page.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <TextBlock TextWrapping="Wrap" Grid.Row="0">
      Select a drive in the combobox then click "Refresh" button. MaxDepth ( an int ) and the MinArea ( in pixels ) controls the recursing levels
    </TextBlock>
    
    <Grid Grid.Row="1">
      
      <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>

      <ComboBox x:Name="_drives" ItemTemplate="{StaticResource driveDataTemplate}"/>
      <ComboBox x:Name="_mode" Grid.Column="1" />
      
      <StackPanel Orientation="Horizontal" Margin="10,0,0,0" Grid.Column="2">
        <Label>MaxDepth</Label>
        <TextBox x:Name="_maxDepth" Text="2" MinWidth="50"/>
      </StackPanel>
      <StackPanel Orientation="Horizontal" Margin="10,0,0,0" Grid.Column="3">
        <Label>MinArea</Label>
        <TextBox x:Name="_minArea" Text="0" MinWidth="50"/>
      </StackPanel>
      <Button Margin="10,0,0,0" Click="ClickRefresh" Grid.Column="4">Refresh</Button>
    </Grid>

    <l:TreeMaps
      Grid.Row="2"
      x:Name="_tree"
      ItemTemplate="{StaticResource diskItemDataTemplate}"
      ValuePropertyName="Value"
      TreeMapMode="Squarified"
      />
    <!--<TreeView Grid.Row="2" x:Name="_tree"
              ItemTemplate="{StaticResource _dtemplate}"/>-->

    <StackPanel Grid.Row="3">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock x:Name="_status" Height="24"/>
        <StackPanel Orientation="Horizontal" HorizontalAlignment ="Right" Grid.Row="1">
          <ProgressBar Width="150" Visibility="Collapsed" x:Name="_progress"  Minimum="0" Maximum="100"/>
        </StackPanel>
      </Grid>
    </StackPanel>
  </Grid>
</Page>
